#import "ArleneNode.h"

#import <UIKit/UIKit.h>

@class ArleneTableRow, ArleneTableSection;

NS_ASSUME_NONNULL_BEGIN

typedef void (^SectionClickEvent) (ArleneTableSection *section);

typedef NS_ENUM (NSUInteger, ArleneTableSectionContentType) {
    ArleneTableSectionContentTypeTitle,
    ArleneTableSectionContentTypeImage,
    ArleneTableSectionContentTypeCustomView
};

@interface ArleneTableSection : ArleneNode

@property (nonatomic, assign) CGFloat headerHeight;
@property (nonatomic, assign) CGFloat footerHeight;
@property (nonatomic, copy, nullable) SectionClickEvent sectionClickEvent;

/**
 *  Initialier set
 *
 */
- (instancetype)initWithTitle:(NSString *)title;
- (instancetype)initWithImage:(UIImage *)image;
- (instancetype)initWithCustomView:(UIView *)customView;

- (void)setTitle:(NSString *)title;
- (void)setImage:(UIImage *)image;
/**
 *  Custom View is default the header of the section, as the setTitle & setImage
 *  Section footer can be treated as a normal row, if you want set header & footer
 *  use the setHeaderView & setFooterView. Or Actually you can use Normal Row as 
 *  Footer(Recommended)
 *
 */
- (void)setCustomeView:(UIView *)customView;

- (void)setHeaderView:(UIView *)customView;
- (void)setFooterView:(UIView *)customView;

/**
 *  Convinent Initializer
 *
 *
 */
+ (ArleneTableSection *)sectionWithTitle:(NSString *)title;
+ (ArleneTableSection *)sectionWithImage:(UIImage *)image;
+ (ArleneTableSection *)sectionWithCustomView:(UIView *)view;

- (UITableViewHeaderFooterView *)viewForTableView:(UITableView *)tableView;
- (UITableViewHeaderFooterView *)viewForHeaderInTableView:(UITableView *)tableView section:(NSInteger)section;
- (UITableViewHeaderFooterView *)viewForFooterInTableView:(UITableView *)tableView section:(NSInteger)section;

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(nonnull UIView *)view forSection:(NSInteger)section;
- (void)tableView:(UITableView *)tableView willDisplayFooterView:(nonnull UIView *)view forSection:(NSInteger)section;

- (CGFloat)heightForHeaderInTableView:(UITableView *)tableView inSection:(NSInteger)section;
- (CGFloat)heightForFooterInTableView:(UITableView *)tableView inSection:(NSInteger)section;

- (nullable NSArray *)allRows;

/**
 All rows will be reset, including exist ones
 *
 */
- (void)setAllRows:(nullable NSArray <__kindof ArleneNode *> *)rows;

- (nullable ArleneTableRow *)rowAtIndex:(NSUInteger)index;


/**
 * Add row into exist ones
 *
 */
- (void)addRow:(nullable __kindof ArleneTableRow *)row;

/**
 * Add rows into exist ones
 *
 */
- (void)addRowsFromArray:(nullable NSArray <__kindof ArleneNode *> *)array;

- (NSUInteger)section;

- (void)loadDataIfneeded;

@end

NS_ASSUME_NONNULL_END
